package com.shengdong.water.code.adapter

import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Lifecycle
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.shengdong.water.feature.main.fragment.MapFragment
import com.shengdong.water.feature.main.fragment.WorkbenchFragment


class MainViewPagerAdapter(fragmentManager: FragmentManager, lifecycle: Lifecycle, private val fragments :List<Fragment> ) : FragmentStateAdapter(fragmentManager,lifecycle) {

    // 页面类型
//    companion object {
//        const val PAGE_WORKBENCH = 0
//        const val PAGE_MAP = 1
//    }
    override fun getItemCount() = fragments.size

    override fun createFragment(position: Int): Fragment {
        return fragments[position]
//        return when (position) {
//            PAGE_WORKBENCH -> WorkbenchFragment()
//            PAGE_MAP -> MapFragment()
//            else -> throw IllegalArgumentException("Invalid position: $position")
//        }
    }
}